Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds billing service #85

Merged
merged 12 commits into from May 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -54,6 +54,7 @@ gem 'activevalidators'
gem 'ancestry'
gem 'aws-sdk-rails'
gem 'rmagick'
gem 'prawn'

# Security
gem 'rack-attack'
@@ -189,8 +189,12 @@ GEM
paper_trail (6.0.2)
activerecord (>= 4.0, < 5.2)
request_store (~> 1.1)
pdf-core (0.7.0)
pg (0.19.0)
phony (2.15.41)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
@@ -324,6 +328,7 @@ GEM
thor (0.19.4)
thread_safe (0.3.5)
tilt (2.0.5)
ttfunk (1.5.1)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
@@ -382,6 +387,7 @@ DEPENDENCIES
newrelic_rpm
paper_trail
pg (~> 0.19)
prawn
pry-byebug
pry-rails
puma (~> 3.0)
@@ -1,22 +1,4 @@
$(document).ready(function(e) {

var contract_duration_type_input = $('#contract_contract_duration_type');
var contract_expected_start_date_input = $('#contract_expected_start_date');
var contract_expected_end_date_input = $('#contract_expected_end_date');
var contract_expected_contract_duration_input = $('#contract_expected_contract_duration');

function contract_update_form_state() {
if(contract_duration_type_input.val() == 'custom') {
contract_expected_end_date_input.removeAttr('disabled');
contract_expected_contract_duration_input.removeAttr('disabled');
} else {
contract_expected_end_date_input.attr('disabled', 'disabled');
contract_expected_contract_duration_input.attr('disabled', 'disabled');
}
};

contract_duration_type_input.on('change', contract_update_form_state);
contract_update_form_state();

});

@@ -0,0 +1,5 @@
$(document).ready(function() {

$("#flash_message").slideDown().delay(3000).slideUp('slow');

});
@@ -1,5 +1,111 @@
$.fn.select2.defaults.set("theme", "bootstrap");


function matchStart (query, item) {
var term = query.term;
if (typeof term == 'undefined' || term == '')
return item;
var text = item.text;
if (text.toUpperCase().indexOf(term.toUpperCase()) != -1) {
return item;
}
var el = $(item.element);
var description = el.data('description') || '';
if (description.toUpperCase().indexOf(term.toUpperCase()) != -1) {
return item;
}
var parent = el.data('parent') || '';
if (parent.toUpperCase().indexOf(term.toUpperCase()) != -1) {
return item;
}
return null;
}

function format_service_select2_option(s) {
if (!s.id)
return '<span class="text-muted">' + s.text + '</span>';
var el = $(s.element);
var type = el.data('type');
var text_right = el.data('text-right');
var parent_service = el.data('parent');
var type_class = el.data('class');
var description = el.data('description');
var parent_service_type = el.data('parent-type');
var template = '<span class="' + type_class + '"><span class="float-right">' + I18n.t('types.service_types.' + type + '.title') + text_right + '</span><i class="' + I18n.t('types.service_types.' + type + '.icon') + '"></i> ' + s.text;
if (typeof parent_service != 'undefined')
template = '<span class="text-muted"><i class="' + I18n.t('types.service_types.' + parent_service_type + '.icon') + '"></i> ' + parent_service + ' <i class="fa fa-fw fa-caret-right"></i></span> ' + template;
template = template + '</span>';
if (typeof description != 'undefined')
template = template + '<br /><small>' + description + '</small>';
return template;
}

function format_service_select2_selection(s) {
if (!s.id)
return '<span class="text-muted">' + s.text + '</span>';
var el = $(s.element);
var type = el.data('type');
var text_right = el.data('text-right');
var parent_service = el.data('parent');
var type_class = el.data('class');
var parent_service_type = el.data('parent-type');
var template = '<span class="' + type_class + '"><span class="float-right">' + I18n.t('types.service_types.' + type + '.title') + text_right + '</span><i class="' + I18n.t('types.service_types.' + type + '.icon') + '"></i> ' + s.text;
if (typeof parent_service != 'undefined')
template = '<span class="text-muted"><i class="' + I18n.t('types.service_types.' + parent_service_type + '.icon') + '"></i> ' + parent_service + ' <i class="fa fa-fw fa-caret-right"></i></span> ' + template;
template = template + '</span>';
return template;
}

function format_select2_result(s) {
if (!s.id)
return s.text;
var el = $(s.element);
var icon = el.data('icon');
var type_class = el.data('class');
var depth = el.data('depth');
var text_right = el.data('text-right');
var description = el.data('description');
var template = '';
if (typeof text_right != 'undefined')
template = template + '<span class="float-right text-muted">' + text_right + '</span>';
if (typeof depth != 'undefined' && depth != '0')
var i = parseInt(depth);
while (i-- >= 0)
template = template + '&nbsp;';
if (typeof icon != 'undefined')
template = template + '<i class="' + icon + '"></i> ';
template = template + '<span class="' + type_class + '">' + s.text + '</span>';
if (typeof description != 'undefined')
template = template + '<br /><small>' + description + '</small>';
return template;
}

function format_select2_selection(s) {
if (!s.id)
return s.text;
var el = $(s.element);
var icon = el.data('icon');
var type_class = el.data('class');
var text_right = el.data('text-right');
var template = '';
if (typeof text_right != 'undefined')
template = template + '<span class="float-right text-muted">' + text_right + '</span>';
if (typeof icon != 'undefined')
template = template + '<i class="' + icon + '"></i> ';
template = template + '<span class="' + type_class + '">' + s.text + '</span>';
return template;
}

window.apply_select2 = function(input) {
input.select2({
language: I18n.locale,
templateResult: format_select2_result,
templateSelection: format_select2_selection,
escapeMarkup: function (markup) { return markup; },
matcher: matchStart
});
};

$(document).ready(function(e) {

$('a[data-toggle="tab"]').click(function (e) {
@@ -19,108 +125,7 @@ $(document).ready(function(e) {
language: I18n.locale
});

function matchStart (query, item) {
var term = query.term;
if (typeof term == 'undefined' || term == '')
return item;
var text = item.text;
if (text.toUpperCase().indexOf(term.toUpperCase()) != -1) {
return item;
}
var el = $(item.element);
var description = el.data('description') || '';
if (description.toUpperCase().indexOf(term.toUpperCase()) != -1) {
return item;
}
var parent = el.data('parent') || '';
if (parent.toUpperCase().indexOf(term.toUpperCase()) != -1) {
return item;
}
return null;
}

function format_select2_result(s) {
if (!s.id)
return s.text;
var el = $(s.element);
var icon = el.data('icon');
var type_class = el.data('class');
var depth = el.data('depth');
var text_right = el.data('text-right');
var description = el.data('description');
var template = '';
if (typeof text_right != 'undefined')
template = template + '<span class="float-right text-muted">' + text_right + '</span>';
if (typeof depth != 'undefined' && depth != '0')
var i = parseInt(depth);
while (i-- >= 0)
template = template + '&nbsp;';
if (typeof icon != 'undefined')
template = template + '<i class="' + icon + '"></i> ';
template = template + '<span class="' + type_class + '">' + s.text + '</span>';
if (typeof description != 'undefined')
template = template + '<br /><small>' + description + '</small>';
return template;
}

function format_select2_selection(s) {
if (!s.id)
return s.text;
var el = $(s.element);
var icon = el.data('icon');
var type_class = el.data('class');
var text_right = el.data('text-right');
var template = '';
if (typeof text_right != 'undefined')
template = template + '<span class="float-right text-muted">' + text_right + '</span>';
if (typeof icon != 'undefined')
template = template + '<i class="' + icon + '"></i> ';
template = template + '<span class="' + type_class + '">' + s.text + '</span>';
return template;
}

$('select.select2').select2({
language: I18n.locale,
templateResult: format_select2_result,
templateSelection: format_select2_selection,
escapeMarkup: function (markup) { return markup; },
matcher: matchStart
});

function format_service_select2_option(s) {
if (!s.id)
return '<span class="text-muted">' + s.text + '</span>';
var el = $(s.element);
var type = el.data('type');
var text_right = el.data('text-right');
var parent_service = el.data('parent');
var type_class = el.data('class');
var description = el.data('description');
var parent_service_type = el.data('parent-type');
var template = '<span class="' + type_class + '"><span class="float-right">' + I18n.t('types.service_types.' + type + '.title') + text_right + '</span><i class="' + I18n.t('types.service_types.' + type + '.icon') + '"></i> ' + s.text;
if (typeof parent_service != 'undefined')
template = '<span class="text-muted"><i class="' + I18n.t('types.service_types.' + parent_service_type + '.icon') + '"></i> ' + parent_service + ' <i class="fa fa-fw fa-caret-right"></i></span> ' + template;
template = template + '</span>';
if (typeof description != 'undefined')
template = template + '<br /><small>' + description + '</small>';
return template;
}

function format_service_select2_selection(s) {
if (!s.id)
return '<span class="text-muted">' + s.text + '</span>';
var el = $(s.element);
var type = el.data('type');
var text_right = el.data('text-right');
var parent_service = el.data('parent');
var type_class = el.data('class');
var parent_service_type = el.data('parent-type');
var template = '<span class="' + type_class + '"><span class="float-right">' + I18n.t('types.service_types.' + type + '.title') + text_right + '</span><i class="' + I18n.t('types.service_types.' + type + '.icon') + '"></i> ' + s.text;
if (typeof parent_service != 'undefined')
template = '<span class="text-muted"><i class="' + I18n.t('types.service_types.' + parent_service_type + '.icon') + '"></i> ' + parent_service + ' <i class="fa fa-fw fa-caret-right"></i></span> ' + template;
template = template + '</span>';
return template;
}
$('select.select2').each(function() {window.apply_select2($(this));});

$('select.services-select2').select2({
language: I18n.locale,
@@ -2,6 +2,7 @@ $(document).ready(function(e) {

if ($('form.edit_price, form#new_price').length > 0) {
var price_pricing_type_input = $('#price_pricing_type');
var price_pricing_duration_type_input = $('#price_pricing_duration_type');
var price_route_id_input = $('#price_route_id');
var price_free_count_input = $('#price_free_count');
var price_deny_after_free_count_true_input = $('#price_deny_after_free_count_true');
@@ -15,6 +16,11 @@ $(document).ready(function(e) {
toggle_input(price_deny_after_free_count_true_input, true);
toggle_input(price_deny_after_free_count_false_input, true);
toggle_input(price_unit_cost_input, true);

if (price_pricing_duration_type_input.val() == 'prepaid') {
price_pricing_duration_type_input.val('monthly');
}
price_pricing_duration_type_input.find('option[value="prepaid"]').prop('disabled', true);
} else {
if (price_pricing_type_input.val() == 'per_call') {
toggle_input(price_route_id_input, false);
@@ -27,7 +33,10 @@ $(document).ready(function(e) {
toggle_input(price_deny_after_free_count_false_input, false);

price_unit_cost_update_input_state();

price_pricing_duration_type_input.find('option[value="prepaid"]').prop('disabled', false);
}
window.apply_select2(price_pricing_duration_type_input);
}

function toggle_input(input, disable) {
@@ -0,0 +1,28 @@
$(document).ready(function(e) {

if ($('form.edit_proxy, form#new_proxy').length > 0) {
var proxy_proxy_parameter_test_attributes_authorization_mode_input = $('#proxy_proxy_parameter_test_attributes_authorization_mode');
var proxy_proxy_parameter_attributes_authorization_mode_input = $('#proxy_proxy_parameter_attributes_authorization_mode');
var proxy_proxy_parameter_test_attributes_authorization_mode_container = $('#proxy_proxy_parameter_test_attributes_authorization_mode_inputs');
var proxy_proxy_parameter_attributes_authorization_mode_container = $('#proxy_proxy_parameter_attributes_authorization_mode_inputs');

function proxy_parameter_form_state() {
if (proxy_proxy_parameter_test_attributes_authorization_mode_input.val() == 'null') {
proxy_proxy_parameter_test_attributes_authorization_mode_container.hide();
} else {
proxy_proxy_parameter_test_attributes_authorization_mode_container.show();
}
if (proxy_proxy_parameter_attributes_authorization_mode_input.val() == 'null') {
proxy_proxy_parameter_attributes_authorization_mode_container.hide();
} else {
proxy_proxy_parameter_attributes_authorization_mode_container.show();
}
}

proxy_proxy_parameter_test_attributes_authorization_mode_input.on('change', proxy_parameter_form_state);
proxy_proxy_parameter_attributes_authorization_mode_input.on('change', proxy_parameter_form_state);
proxy_parameter_form_state();
}

});